home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / DIALOG.ZIP / DBPRO2-@.EXE / DBPRO.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-20  |  29.0 KB  |  999 lines

  1. #include "dbops.h"
  2.  
  3. /* question types */
  4. #define FREE_FORM                            1
  5. #define MULTI_CHOICE                        2
  6. #define TITLE                                3
  7. #define BUTTON                                4
  8. #define REDUCE                                5
  9. #define LIST                                6
  10. #define SCROLLING_TEXT                        7
  11. #define RCBUTTON                            8
  12.  
  13. #define CURRQ                (db_ptr->questions[db_ptr->id_select])
  14. #define CURRTILE            (db_ptr->questions[db_ptr->id_select])[1]
  15. #define CURRAVAIL            (db_ptr->available[db_ptr->id_select])
  16. #define LISTAVAIL            (list_ptr->available[list_ptr->selected] == 1)
  17. #define LISTTITLE            (list_ptr->available[list_ptr->selected] == 2)
  18. #define CURRMC                ((multi_choice *)(db_ptr->questions[db_ptr->id_select]))
  19. #define CURRSCROLLQ            ((scroll_txt *)(db_ptr->questions[db_ptr->id_select]))
  20. #define CURRFF                ((free_form *)(db_ptr->questions[db_ptr->id_select]))
  21. #define CURRR                ((reducer *)(db_ptr->questions[db_ptr->id_select]))
  22. #define CURRBUTTON            ((button *)(db_ptr->questions[db_ptr->id_select]))
  23. #define CURRRCBUTTON        ((rcbutton *)(db_ptr->questions[db_ptr->id_select]))
  24. #define CURRLIST            ((list *)(db_ptr->questions[db_ptr->id_select]))
  25. #define DBERROR(errnum,    functnum) {db_errorhandler(errnum,functnum); return(errnum);}
  26. #define MCQUEST(id)            ((multi_choice *)(db_ptr->questions[id]))
  27. #define FFQUEST(id)            ((free_form *)(db_ptr->questions[id]))
  28. #define ROOTQUEST(id)        ((root *)(db_ptr->questions[id]))
  29. #define RQUEST(id)            ((reducer *)(db_ptr->questions[id]))
  30. #define BUTTONQUEST(id)        ((button *)(db_ptr->questions[id]))
  31. #define RCBUTTONQUEST(id)    ((rcbutton *)(db_ptr->questions[id]))
  32. #define LISTQUEST(id)        ((list *)(db_ptr->questions[id]))
  33. #define TITLEQUEST(id)        ((title *)(db_ptr->questions[id]))
  34. #define SCROLLQUEST(id)        ((scroll_txt *)(db_ptr->questions[id]))
  35. #define QTYPE(id)            *((char *)(db_ptr->questions[id]))
  36. #define NO_EVENT            ((*db_head) == (*db_tail))
  37. #define DB_MOVABLE            db_ptr->move_ok
  38. #define LST_MOVABLE            list_ptr->move_ok
  39. #define DB_SIZABLE            db_ptr->size_ok
  40. #define LST_SIZABLE            list_ptr->size_ok
  41. #define ID_NEXT                (db_ptr->questions[db_ptr->id_select+1] ? db_ptr->id_select + 1 : 0)
  42. #define ID_PREV                (db_ptr->id_select ? db_ptr->id_select - 1 : db_lastq(db_ptr))
  43. #define makemacro(name,key,function)    unsigned long name[] = {key+(3*65536L),(unsigned long) function,EXECUTE};
  44.  
  45. /* list types */
  46. #define CHECKLIST                            1
  47. #define SELECT_ONE                            2
  48.  
  49. /* rc button types */
  50. #define CHECK                                0
  51. #define RADIO(n)                            (1+n)
  52.  
  53. typedef struct {
  54.  
  55.     /* foreground and background colors of titles */
  56.     unsigned char title_bg, title_fg;
  57.  
  58.     /*
  59.      * foreground and background colors of the statement portion
  60.      * of questions
  61.     */
  62.     unsigned char question_bg, question_fg;
  63.  
  64.     /*
  65.      * foreground and background colors of the response portion
  66.      * of questions: available, unavailable, selected unavailable, &
  67.      * selected available.
  68.     */
  69.     unsigned char response_bg, response_fg;
  70.     unsigned char un_bg, un_fg;
  71.     unsigned char sun_bg, sun_fg;
  72.     unsigned char select_bg, select_fg;
  73.  
  74.     /*
  75.      * foreground & background colors of the shortcut keys
  76.     */
  77.     unsigned char key_bg, key_fg;
  78.  
  79.     /*
  80.      * foreground and background colors to be used when editing a
  81.      * text response.
  82.     */
  83.     unsigned char edit_bg, edit_fg;
  84.  
  85. } db_colors;
  86.  
  87. typedef struct {
  88.  
  89.     /*
  90.      * The characters to place around the response portion of a free
  91.      * form question.  These character arrays are defined the same
  92.      * as the window border character arrays.  Note that any NULL
  93.      * characters are simply not output.  This means that you do not
  94.      * have to triple space questions as you would by putting a
  95.      * complete box around each, but could just define delimiters
  96.      * on either side (as in DBPRO 1.1) or even none at all.
  97.     */
  98.     unsigned char *ff_boxchars;
  99.  
  100.     /* multiple choice delimiters */
  101.     unsigned char *mc_boxchars;
  102.  
  103.     /* reducer delimiters */
  104.     unsigned char *r_boxchars;
  105.  
  106.     /*
  107.      * the characters to place to the left of a check box when checked
  108.      * and not checked -- note that these must be the same length!
  109.     */
  110.     char *check_on, *check_off;
  111.  
  112.     /*
  113.      * the characters to place to the left of a radio button when checked
  114.      * and not checked -- note that these must be the same length!
  115.     */
  116.     char *radio_on, *radio_off;
  117.  
  118. } db_delimiters;
  119.  
  120. /* storage record -- keeps previous answers to a dialog box in case of abort */
  121. typedef struct {
  122.  
  123.     /* type of question being stored */
  124.     unsigned char question_type;
  125.  
  126.     /* the question's id */
  127.     unsigned char id;
  128.  
  129.     /*
  130.      * pointer to the next storage record -- used in creating a linked
  131.      * list of storage records to let you preserve a snapshot of the
  132.      * db at any point
  133.     */
  134.     void *next;
  135.  
  136.     /*
  137.      * Used to store either -- a pointer to a string for the response
  138.      * to a free form question or an integer representing an offset
  139.      * into a multiple choice list
  140.     */
  141.     void *keeper;
  142.  
  143. } storage;
  144.  
  145.  
  146. /*
  147.  * the state of the list is temporarily stored in this structure on a
  148.  * call to lst_run.  If the user confirms the list -- then this data
  149.  * is discarded otherwise it is used to restore the list to its previous
  150.  * state.
  151. */
  152.  
  153. typedef struct {
  154.     char *selections;
  155.     int selected;
  156. } lst_storage;
  157.  
  158. /* list handler record */
  159. typedef struct {
  160.  
  161.     unsigned handle;                /* a window where the list will be
  162.                                        be displayed */
  163.     unsigned char tile_handle;        /* the tile within the window where
  164.                                        the list will be displayed */
  165.     char list_type;                    /* CHECKLIST or SELECTONE */
  166.     char move_ok, size_ok;            /* is the window movable/sizable? */
  167.     char auto_vert;                    /* resize the viewport vertically to
  168.                                        match the width of the elements
  169.                                        within the list on each call to
  170.                                        lst_run */
  171.     char auto_horiz;                /* resize the viewport horizontally
  172.                                        to match the number of elements
  173.                                        within the list on each call to
  174.                                        lst_run */
  175.     char alpha_confirm;                /* Pressing the shortcut key of an
  176.                                        item toggle it on off? */
  177.     char bg_operation;                /* of FALSE the window is brought
  178.                                        to the top of the stack of windows
  179.                                        on each call to lst_run */
  180.     int selected;                    /* the currently selected element */
  181.     int numopts, taglen, optlen;    /* used internally by lst_run */
  182.     unsigned *cmds;                    /* keyboard command table used in this
  183.                                        list */
  184.     char *on, *off;                    /* the strings to place to the left of
  185.                                        of each element to indicate whether
  186.                                        an items is toggled on or off */
  187.     char **options;                    /* a null terminated list of char strings
  188.                                        representing the elements of the list */
  189.     char *selections;                /* a list of chars which corresponds to the
  190.                                        list of elements where: 1 = toggled on,
  191.                                        2 = toggled off. */
  192.     char *available;                /* a list of chars which corresponds to the
  193.                                        list of elements where: 0 = element
  194.                                        can not be toggled, 1 = element can
  195.                                        be toggled, and 2 = element is a title */
  196.     unsigned *keybind;                /* a list of keyboard codes which corresponds
  197.                                        to the list of elements representing
  198.                                        the shortcut key for each element */
  199.     db_colors *colors;                /* the color scheme to be used when
  200.                                        displaying the list */
  201.     lst_storage *insurance;            /* set to NULL. Used internally */
  202.     unsigned **macros;                /* a list of local macros for the list */
  203.     unsigned maxcols;                /* a list of the maximum number of side
  204.                                        by side columns to display the elements
  205.                                        in. */
  206.     unsigned                        /* this info is used to create a valid */
  207.         physical_x,                    /* window to display the list in if the */
  208.         physical_y,                    /* window handle (above) is not valid */
  209.         virtual_x, virtual_y,
  210.         virtual_rows,
  211.         virtual_columns,
  212.         port_rows,
  213.         port_columns,
  214.         shading;
  215.     char *name1,
  216.         *name2;
  217.     unsigned char
  218.         *boxchars;
  219. } list_rec;
  220.  
  221. /*
  222.  * all question types (except titles) have this same info in these
  223.  * same positions.  This type is used to access these values from
  224.  * any question pointer.
  225. */
  226. typedef struct {
  227.     char question_type;
  228.     unsigned char tile_handle;
  229.     int (*whenon)(void *);
  230.     int (*whenoff)(void *);
  231.     int (*action)(void *);
  232.     char *statement;
  233.     int statementx, statementy;
  234.     unsigned key;
  235. } root;
  236.  
  237. /* free form question record */
  238. typedef struct {
  239.  
  240.     /* Must be set equal to FREE_FORM */
  241.     char question_type;
  242.  
  243.     /* tile to display the question in */
  244.     unsigned char tile_handle;
  245.  
  246.     /*
  247.      * pointer to edit check routines -- you can use this to
  248.      * check that a string represents a valid number, etc. that
  249.      * the item is within a certain range etc.  The routine must
  250.      * return an integer.
  251.      *
  252.      * Set this value to NULL to perform no edit checking on the
  253.      * question.
  254.     */
  255.     int (*whenon)(void *);
  256.  
  257.     /*
  258.      * same as above except it does not allow the user to navigate
  259.      * off of the question until the routine returns TRUE
  260.     */
  261.     int (*whenoff)(void *);
  262.  
  263.     /*
  264.      * same as above but does not allow a user to exit a question
  265.      * until it returns TRUE.
  266.     */
  267.     int (*action)(void *);
  268.  
  269.     /* statement portion of the question -- e.g. How many inches? */
  270.     char *statement;
  271.  
  272.     /* the statement begins at this coordinate */
  273.     int statementx, statementy;
  274.  
  275.     /* short cut key for navigating to this question */
  276.     unsigned key;
  277.  
  278.     /*
  279.      * the current response to the question; This must be a dynamically
  280.      * allocated string (or NULL) because db_run will free this and replace it
  281.      * with the edited version.
  282.     */
  283.     char *response;
  284.  
  285.     /*
  286.      * If response (above) is NULL db_run automatically creates a dynamically
  287.      * allocated duplicate of this string and assigns it to response.
  288.     */
  289.     char *default_response;
  290.  
  291.     /* the beginning coordinate of the response */
  292.     int responsex, responsey;
  293.  
  294.     /*
  295.      * the maximum displayed length of the response -- the actual
  296.      * length can be longer
  297.     */
  298.     int responselen;
  299.  
  300.     /*
  301.      * used internally
  302.     */
  303.     char *insurance,
  304.  
  305.     /*
  306.      * this pointer is set to the the value of response (above) on
  307.      * exiting the dialog box.  This introduces two copies of a
  308.      * a dynamically allocated variable -- do not free this pointer
  309.      * without setting response (above) to NULL.  Otherwise, next time
  310.      * you execute db_run response (above) will be free'd corrupting
  311.      * the heap.
  312.     */
  313.     **target;
  314.  
  315.     /*
  316.      * the default cursor position when entering edlin.  Normally
  317.      * this is set to the last character in the string on exiting
  318.      * the line editor.  But if you prefer to not do this you can
  319.      * remove the statement from db_edlin whereupon this variable
  320.      * will hold the position of the cursor in the line editor when
  321.      * you last exited the question.
  322.     */
  323.     int cursor_position;
  324.  
  325.     /* local macro definitions */
  326.     unsigned **macros;
  327.  
  328.     /*
  329.      * If TRUE statement, delimiters, and response are
  330.      * redrawn. Otherwise, just the response are is redrawn.
  331.      * This flag is set to FALSE after drawing the statement,
  332.      * delimiters, and response
  333.     */
  334.     char refresh;
  335.  
  336. } free_form;
  337.  
  338. /* list question record */
  339. typedef struct {
  340.  
  341.     /* Must be set equal to LIST */
  342.     char question_type;
  343.  
  344.     /* tile to display the question in */
  345.     unsigned char tile_handle;
  346.  
  347.     /*
  348.      * edit check routines -- see explanation in free_form.
  349.     */
  350.     int (*whenon)(void *);
  351.     int (*whenoff)(void *);
  352.     int (*action)(void *);
  353.  
  354.     /* the title of the list */
  355.     char *statement;
  356.  
  357.     /* the statement begins at this coordinate */
  358.     int statementx, statementy;
  359.  
  360.     /* shortcut key */
  361.     unsigned key;
  362.  
  363.     /* CHECKLIST or SELECTONE */
  364.     char list_type;
  365.  
  366.     /* a list question uses a window for some interim stuff -- supply a handle here */
  367.     unsigned handle;
  368.  
  369.     unsigned                /* if handle (above) is not a valid handle */
  370.         virtual_rows,        /* we use this info to create a window */
  371.         virtual_columns,
  372.         physical_x,
  373.         physical_y,
  374.         virtual_x,
  375.         virtual_y,
  376.         port_rows,
  377.         port_columns,
  378.         shading;
  379.     char *name1, *
  380.         name2;
  381.     unsigned char *boxchars,
  382.         scroll_bars;
  383.  
  384.     /* the currently selected item in the list */
  385.     int offset;
  386.  
  387.     /* the items in the list */
  388.     char **options;
  389.  
  390.     /* are they available -- see explanation in list_rec */
  391.     char *available;
  392.  
  393.     /* which are toggled on/off -- see explanation in list_rec */
  394.     char *selected;
  395.  
  396.     /* the on -- off designators */
  397.     char *on, *off;
  398.  
  399.     /* list pointer -- normally set to NULL -- used internally */
  400.     list_rec *list_ptr;
  401.  
  402.     /* set to the value of selected (above) when the db is exited */
  403.     char **target;
  404.  
  405.     /* macro definitions */
  406.     unsigned **macros;
  407.  
  408.     /*
  409.      * set this to TRUE if you have modified any members of this
  410.      * structure.  Always set to TRUE on first usage.
  411.     */
  412.     char refresh;
  413.  
  414.     /*
  415.      * set to TRUE if on selecting the list you want to automatically
  416.      * place the cursor in the list -- note that after you
  417.      * exit a list this value is set to TRUE.   Set this to FALSE
  418.      * initially for MAC/WINDOWS-like behavior.
  419.     */
  420.     char autodescend;
  421.  
  422.     /*
  423.      * if you want a simple vertical list use 1.  If you want two
  424.      * columns side by side set to 2.  If you want the minimum number
  425.      * of columns required given the height of the list's viewport
  426.      * set this to MAXINT.
  427.     */
  428.     unsigned maxcols;
  429.  
  430. } list;
  431.  
  432. /* scrolling text question record */
  433. typedef struct {
  434.  
  435.     /* Must be set equal to SCROLLING_TEXT */
  436.     char question_type;
  437.  
  438.     /* tile to display the question in */
  439.     unsigned char tile_handle;
  440.  
  441.     /* edit check routines -- see free_form for explanation */
  442.     int (*whenon)(void *);
  443.     int (*whenoff)(void *);
  444.     int (*action)(void *);
  445.  
  446.     /* box title */
  447.     char *statement;
  448.  
  449.     /* coordinates for the sub-box */
  450.     unsigned statementx, statementy;
  451.  
  452.     /* shortcut key */
  453.     unsigned key;
  454.  
  455.     /*
  456.      * the function which is called on entering the question -- determines
  457.      * behavior of the question.
  458.     */
  459.     int (far *control)(void *, int);
  460.  
  461.     /*
  462.      * use to associate additional data with the text, you might
  463.      * use this data in edit checking or action routines.
  464.     */
  465.     void *misc_ptr;
  466.  
  467.     /*
  468.      * the box is in this position in the dialog box
  469.      * You should set it to the appropriate size before calling the
  470.      * dialog box.
  471.     */
  472.     int boxx, boxy;
  473.  
  474.     /* uses a window for some interim stuff -- supply a handle here */
  475.     unsigned aux_handle;
  476.  
  477.     /* macro definitions */
  478.     unsigned **macros;
  479.  
  480. } scroll_txt;
  481.  
  482. /* multiple choice question record */
  483. typedef struct {
  484.  
  485.     /* must be set to MULTI_CHOICE */
  486.     char question_type;
  487.  
  488.     /* the tile to display the question in */
  489.     unsigned char tile_handle;
  490.  
  491.     /*
  492.      * edit check routines -- see free_form for explanation
  493.     */
  494.     int (*whenon)(void *);
  495.     int (*whenoff)(void *);
  496.     int (*action)(void *);
  497.  
  498.     /* the statement portion of the question */
  499.     char *statement;
  500.  
  501.     /* begin displaying the statement at these coordinates */
  502.     int statementx, statementy;
  503.  
  504.     /* shortcut key */
  505.     unsigned key;
  506.  
  507.     /*
  508.      * response mask -- will display this string in place of the
  509.      * current response.  Normally set to NULL but is useful
  510.      * in creating a menu bar type dialog box, where the menu bar
  511.      * represents a series of multiple choice questions.  Or in
  512.      * inserting pulldown menus anywhere in a dialog box.
  513.     */
  514.     char *response_mask;
  515.  
  516.     /* Pointer to an array of pointers -- pointing to each of the
  517.      * available responses in a multiple choice question.  The
  518.      * last pointer in the array must be a null pointer.
  519.     */
  520.     char **response_list;
  521.  
  522.     /*
  523.      * corresponds to above array.  A value of TRUE indicates that
  524.      * the item is available for selection.  FALSE, it is not. 2 if
  525.      * the element is a title.
  526.     */
  527.     char *available;
  528.  
  529.     /*
  530.      * The offset into the above array representing the current response
  531.      * to the question.
  532.     */
  533.     int response_offset;
  534.  
  535.     /* the beginning coordinate of the response */
  536.     int responsex, responsey;
  537.  
  538.     /*
  539.      * the maximum displayed length of the response -- the actual
  540.      * length can be longer
  541.     */
  542.     int responselen;
  543.  
  544.     /* window and tile to display the pull down list in */
  545.     unsigned aux_handle;
  546.     unsigned char aux_tile;
  547.  
  548.     /*
  549.      * if the handle (above) is invalid use this info to create
  550.      * a window
  551.     */
  552.     unsigned char
  553.         *boxchars;
  554.     char *major_head,
  555.         *minor_head,
  556.         shading;
  557.  
  558.     /* list pointer -- normally set to NULL -- used internally */
  559.     list_rec *list_ptr;
  560.  
  561.     /* set to the value of response_offset on exiting the dialog box */
  562.     int *target;
  563.  
  564.     /* macro definitions */
  565.     unsigned **macros;
  566.  
  567.     /*
  568.      * indicate the number of side by side columns desired in the pull
  569.      * down list.  use 1 for a vertical list, MAXINT for a horizontal list,
  570.      * 2 for a 2 column vertical list, etc.
  571.     */
  572.     unsigned maxcols;
  573.  
  574.     /*
  575.      * If TRUE statement, delimiters, and response are
  576.      * redrawn. Otherwise, just the response are is redrawn.
  577.      * This flag is set to FALSE after drawing the statement,
  578.      * delimiters, and response
  579.     */
  580.     char refresh;
  581.  
  582. } multi_choice;
  583.  
  584. /* reducer question record */
  585. typedef struct {
  586.  
  587.     /* must be set to REDUCER */
  588.     char question_type;
  589.  
  590.     /* the tile to display the question in */
  591.     unsigned char tile_handle;
  592.  
  593.     /*
  594.      * edit checking routines -- see free_form for explanation
  595.     */
  596.     int (*whenon)(void *);
  597.     int (*whenoff)(void *);
  598.     int (*action)(void *);
  599.  
  600.     /* the statement portion of the question */
  601.     char *statement;
  602.  
  603.     /* begin displaying the statement at these coordinates */
  604.     int statementx, statementy;
  605.  
  606.     /* shortcut key */
  607.     unsigned key;
  608.  
  609.     /* Pointer to an array of pointers -- pointing to each of the
  610.      * available responses in a reducer question.  The
  611.      * last pointer in the array must be a null pointer.
  612.     */
  613.     char **response_list;
  614.  
  615.     /*
  616.      * corresponds to above array.  A value of TRUE indicates that
  617.      * the item is available for selection.  FALSE, it is not. 2 is
  618.      * a title.
  619.     */
  620.     char *available;
  621.  
  622.     /*
  623.      * the current response -- must be a dynamically allocated string
  624.      * just like in a free_form question. or NULL.  If NULL a dynamically
  625.      * allocated string is created from default_response.
  626.     */
  627.     char *response;
  628.     char *default_response;
  629.  
  630.     /* the beginning coordinate of the response */
  631.     int responsex, responsey;
  632.  
  633.     /*
  634.      * the maximum displayed length of the response -- the actual
  635.      * length can be longer
  636.     */
  637.     int responselen;
  638.  
  639.     /* see multi_choice for explanation */
  640.     unsigned aux_handle;
  641.     unsigned char aux_tile;
  642.     unsigned char *boxchars;
  643.     char *major_head, *minor_head, shading;
  644.  
  645.     /* set to NULL -- used internally */
  646.     list_rec *list_ptr;
  647.     char *insurance,
  648.  
  649.     /* set to the value of the list element selected. */
  650.     **target;
  651.  
  652.     /* see free_form for explanation */
  653.     int cursor_position;
  654.  
  655.     /* macro definitions */
  656.     unsigned **list_macros;
  657.     unsigned **edlin_macros;
  658.  
  659.     /* see multi_choice for explanation */
  660.     unsigned maxcols;
  661.  
  662.     /*
  663.      * If TRUE statement, delimiters, and response are
  664.      * redrawn. Otherwise, just the response are is redrawn.
  665.      * This flag is set to FALSE after drawing the statement,
  666.      * delimiters, and response
  667.     */
  668.     char refresh;
  669.  
  670. } reducer;
  671.  
  672.  
  673. /* title record */
  674. typedef struct {
  675.  
  676.     /* MUST be set to TITLE */
  677.     char question_type;
  678.  
  679.     /* tile to display the title in */
  680.     unsigned char tile_handle;
  681.  
  682.     /* the title itself */
  683.     char *statement;
  684.  
  685.     /* beginning coordinate of the title */
  686.     int statementx, statementy;
  687.  
  688.     /* center justifies the title if TRUE */
  689.     char center_justify;
  690.  
  691.  
  692. } title;
  693.  
  694.  
  695. /* button record */
  696. typedef struct {
  697.  
  698.     /* MUST be set to BUTTON */
  699.     char question_type;
  700.  
  701.     /* the tile to display the question in */
  702.     unsigned char tile_handle;
  703.  
  704.     /*
  705.      * see free_form for explanation
  706.     */
  707.     int (*whenon)(void *);
  708.     int (*whenoff)(void *);
  709.     int (*action)(void *);
  710.  
  711.     /* the statement portion of the question */
  712.     char *statement;
  713.  
  714.     /*
  715.      * coordinate to display the button at
  716.     */
  717.     int statementx, statementy;
  718.  
  719.     /* shorcut key */
  720.     unsigned key;
  721.  
  722.     /*
  723.      * array of characters to be used in building the box around
  724.      * the statement -- set to NULL for no box
  725.     */
  726.     unsigned char *boxchars;
  727.  
  728.     /*
  729.      * Shading to be used in making a box around the statement
  730.     */
  731.     char shading;
  732.  
  733.     /*
  734.      * Resets the keyboard code on pressing a button to this value.
  735.      * This lets you use buttons like an extension of the keyboard.
  736.      * You can have buttons that mimic hitting the ENTER key, etc.
  737.     */
  738.     unsigned cmdkey;
  739.  
  740.     /*
  741.      * This value binds a keyboard code to a button.  This way you
  742.      * don't actually have to navigate to a button to 'press it.'
  743.     */
  744.     unsigned keybind;
  745.  
  746.     /*
  747.      * if TRUE, holding the mouse on the button will continually
  748.      * put the value key (above) onto the queue
  749.     */
  750.     char continuous;
  751.  
  752.     /*
  753.      * This lets you modify the exit value from db_run on pressing a
  754.      * button.  This code can then let your application know which
  755.      * button was pressed -- in order to perform the proper operation
  756.     */
  757.     unsigned exitval;
  758.  
  759. } button;
  760.  
  761. /* radio/check button record */
  762. typedef struct {
  763.  
  764.     /* MUST be set to RCBUTTON */
  765.     char question_type;
  766.  
  767.     /* the tile to display the question in */
  768.     unsigned char tile_handle;
  769.  
  770.     /* edit checking routines */
  771.     int (*whenon)(void *);
  772.     int (*whenoff)(void *);
  773.     int (*action)(void *);
  774.  
  775.     /* the statement portion of the question */
  776.     char *statement;
  777.  
  778.     /*
  779.      * coordinate to display the radio button/checkbox at
  780.     */
  781.     int statementx, statementy;
  782.  
  783.     /* the keyboard code for the shortcut key */
  784.     unsigned key;
  785.  
  786.     /* CHECK or RADIO(N) where N indicates a group number from 0 to 254 */
  787.     unsigned char btype;
  788.  
  789.     /* TRUE if the button is checked */
  790.     char checked;
  791.  
  792.     /* set to the value of checked (above) when the dialog box is exited */
  793.     char *target;
  794.  
  795. } rcbutton;
  796.  
  797. /* db record */
  798. typedef struct {
  799.  
  800.     unsigned handle;            /* window where the db will be displayed */
  801.     int (*post_size)(void *);    /* if window is resized this function is called */
  802.     int (*post_move)(void *);    /* if window is moved this function is called */
  803.     char move_ok, size_ok;        /* allows moving and/or sizing */
  804.     void **questions;            /* a null terminated list of pointers to the
  805.                                    questions composing the db */
  806.     char *available;            /* a list of chars indicating which questions
  807.                                    can be modified, where 0 = NO, 1 = YES */
  808.     unsigned char id_select;    /* the question which will initially be
  809.                                    selected */
  810.     unsigned *cmds;                /* keyboard command table -- i.e. which keys
  811.                                    are bound to which operations */
  812.     char bg_operation;            /* if FALSE the dialog box window is always
  813.                                    brought to the top of the stack of windows
  814.                                    when the dbrun is called. */
  815.     db_colors *colors;            /* a pointer to the color scheme to be used
  816.                                    in this db */
  817.     db_delimiters *delimiters;    /* a pointer to the delimiter types to use
  818.                                    when displaying the questions in this
  819.                                    dialog box */
  820.     storage *insurance;            /* set this to NULL.  This pointer is used
  821.                                    to keep a record of the dialog box
  822.                                    responses, before any changes are made.
  823.                                    This record can then be used to restore
  824.                                    the dialog box answers is necessary */
  825.     unsigned **macros;            /* a list of local macros to be used in this
  826.                                    dialog box */
  827.     unsigned                    /* all of this info is used to create a */
  828.         virtual_rows,            /* window to display the dialog box if  */
  829.         virtual_columns,        /* the handle specified above is not a  */
  830.         physical_x,                /* valid window handle */
  831.         physical_y,
  832.         virtual_x,
  833.         virtual_y,
  834.         port_rows,
  835.         port_columns,
  836.         shading;
  837.     char *name1,
  838.         *name2;
  839.     unsigned char
  840.         *boxchars,
  841.         scroll_bars,
  842.         fg, bg;
  843. } dialog_box;
  844.  
  845. extern int         db_display(dialog_box *);
  846. extern int         db_display_title(dialog_box *, title *);
  847. extern int         db_display_ff(dialog_box *, free_form *, char, char);
  848. extern int         db_display_mc(dialog_box *, multi_choice *, char, char);
  849. extern int         db_display_button(dialog_box *, button *, char, char);
  850. extern int         db_display_rcbutton(dialog_box *, rcbutton *, char, char);
  851. extern void     clearradiobutton(dialog_box *, unsigned char);
  852. extern int         db_display_scroll(dialog_box *, int);
  853. extern int         db_display_r(dialog_box *, reducer *, char, char);
  854. extern int         db_displayq(dialog_box *, unsigned char);
  855. extern int         db_selectq(dialog_box *, unsigned char);
  856. extern int         db_run(dialog_box *, unsigned);
  857. extern int         db_touchbutton(dialog_box *, unsigned *);
  858. extern int         db_storeanswers(dialog_box *, storage **);
  859. extern int         db_restoreanswers(dialog_box *, storage **);
  860. extern int         db_freestorage(dialog_box *, storage **);
  861. extern int         db_getopcode(int, unsigned*);
  862. extern int         db_rlist(dialog_box *, int, char **, char**, char*);
  863. extern char **    db_reductionstr(char **, char **, char *);
  864. extern int         db_interp_mouseclicks(dialog_box *, int, unsigned *,
  865.                 unsigned *, int *);
  866. extern int         db_onquestion(dialog_box *, int *, int, int,
  867.                 unsigned char, int *);
  868. extern int         db_mclist(dialog_box *, int, int *);
  869. extern int         lst_interpmouse(list_rec *, int, unsigned *, unsigned *,
  870.                 int *, unsigned, unsigned);
  871. extern int         lst_freestorage(lst_storage **);
  872. extern int         lst_restoreanswers(list_rec *, lst_storage **);
  873. extern int         lst_storeanswers(list_rec *, lst_storage**);
  874. extern int         lst_toggle(list_rec *, int);
  875. extern int         lst_displayitem(list_rec *, int);
  876. extern int         lst_select(list_rec *, int);
  877. extern int         lst_run(list_rec *, unsigned);
  878. extern int         lst_runp(list_rec *, unsigned, dialog_box *);
  879. extern int         lst_longestoption(list_rec *, int*);
  880. extern int         lst_display(list_rec *, unsigned char);
  881. extern int         lst_numopts(list_rec *);
  882. extern void     do_editcheckin(dialog_box *);
  883. extern int         do_editcheckout(dialog_box *);
  884. extern int         db_push(unsigned);
  885. extern int         db_priority(unsigned);
  886. extern unsigned    db_pop(void);
  887. extern int         db_pushw(unsigned long);
  888. extern int         db_priorityw(unsigned long);
  889. extern unsigned long
  890.                 db_popw(void);
  891. extern int         run_free_form(dialog_box *, int, char);
  892. extern int         run_multi_choice(dialog_box *);
  893. extern int         run_reducer(dialog_box *, int, char);
  894. extern int         force_cur(unsigned, unsigned char, unsigned, unsigned);
  895. extern void     db_errorhandler(signed int, signed int);
  896. extern unsigned get_event(void *);
  897. extern int         db_runlist(dialog_box *, int, int *, int);
  898. extern int         db_edlin(unsigned, unsigned char, char **, char, int, int,
  899.                 int, int, int, unsigned char, unsigned char, unsigned *,
  900.                 char**, int*, int, unsigned **, dialog_box *);
  901. extern int         db_executemacros(unsigned, unsigned **);
  902. extern void     db_switchqueue(unsigned char *, unsigned char *, unsigned *);
  903. extern void     db_flushqueue(void);
  904. extern void     do_post_wdw(dialog_box *, int);
  905. extern void     do_post_size(dialog_box *);
  906. extern void     do_post_move(dialog_box *);
  907. extern void     do_action(dialog_box *);
  908. extern int         run_window(unsigned, unsigned char, int);
  909. extern int         wn_draww_on_vs(unsigned, unsigned, unsigned char);
  910. extern int         db_updatetargets(dialog_box *);
  911. extern int         do_control(dialog_box *, int);
  912. extern int         db_runscroll(dialog_box *, int);
  913. extern int         db_run_subdb(dialog_box *, int);
  914. extern void     db_adjustvs(dialog_box *);
  915. extern void     q_open(unsigned);
  916. extern void     q_close(void);
  917. extern void     db_display_subdb(dialog_box *);
  918. extern int         alt(char);
  919. extern int         caps_lock(void);
  920. extern int         scroll_lock(void);
  921. extern int         vs_putcods(unsigned, unsigned char, unsigned, unsigned,
  922.                 unsigned, unsigned char, unsigned char, unsigned char,
  923.                 unsigned char, char *);
  924. extern int         db_touchbuttonk(dialog_box *, unsigned *, unsigned *, unsigned char *, unsigned char *);
  925. extern free_form*
  926.                 create_ff(char *);
  927. extern void     destroy_ff(free_form *);
  928. extern multi_choice*
  929.                 create_mc(char *);
  930. extern multi_choice*
  931.                 create_pd(char *);
  932. extern void     destroy_mc(multi_choice *);
  933. extern rcbutton*
  934.                 create_rb(char *);
  935. extern void     destroy_rb(rcbutton *);
  936. extern rcbutton*
  937.                 create_cb(char *);
  938. extern list*    create_lt(char *);
  939. extern void     destroy_lt(list *);
  940. extern button*    create_bt(char *);
  941. extern void     destroy_bt(button *);
  942. extern void     write_ln(unsigned, char *);
  943. extern void     read_ln(unsigned, char *, unsigned);
  944. extern dialog_box*
  945.                 create_db(int ,unsigned long, int,
  946.                     unsigned long, unsigned);
  947. extern void     destroy_db(dialog_box *);
  948.  
  949. /* db globals */
  950.  
  951. /* pointer to offsets into the current queue */
  952. extern unsigned char *db_head, *db_tail;
  953.  
  954. /* pointer a 256 byte queue */
  955. extern unsigned    *db_queue;
  956.  
  957. /*
  958.  * determines how sensitive the mouse is to clicks, etc. -- set to 10 or 15 for
  959.  * best results
  960. */
  961. extern unsigned mouse_sensitivity;
  962.  
  963. /* a default keyboard command table */
  964. extern unsigned default_db_cmds[NUM_OPS];
  965.  
  966. /* used internally */
  967. extern int force_list_update;
  968. extern unsigned long prev_event, curr_event;
  969. extern unsigned press_button;
  970. extern unsigned char ascii;
  971. extern int mouse_timeout;
  972. extern char monitor_buffer[];
  973.  
  974.  
  975. /* window to display the dbqueue mnemonic codes in -- useful for debugging */
  976. extern unsigned monitor_wdw;
  977. extern unsigned char monitor_tile;
  978.  
  979. extern int monitor_speed;    /* 0 = by keypress, 1 > sleep interval between
  980.                                opcodes */
  981.  
  982. extern int monitor_switch;    /* TRUE is monitor is on, FALSE is off. */
  983.  
  984. /* colors to display the opcodes in */
  985. extern unsigned char monitor_fg, monitor_bg;
  986.  
  987. /* some useful default color and delimiter schemes */
  988. extern db_colors default_db_colors, msmono;
  989. extern db_delimiters default_db_delimiters;
  990.  
  991. /* this function is called repeatedly during the keyboard/mouse polling loop */
  992. extern int (far *idle)(void *);
  993.  
  994. /*
  995.  * when macros are processed -- all codes are passed through this list
  996.  * before being passed on to the local macro list
  997. */
  998. extern unsigned **global_macros;
  999.